﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ECode.ECommon.Extensions;

namespace ECode.ModbusTester.Lib.ViewModel
{
    /// <summary>
    /// 计数器ViewModel
    /// </summary>
    public class CounterViewModel:BaseViewModel
    {
        #region
        private string _sendCount;
        /// <summary>
        /// 发送计数
        /// </summary>
        public string SendCount { get{return _sendCount;} set { _sendCount = value;OnPropertyChanged("SendCount"); } }

        private string _recCount;
        /// <summary>
        /// 接收计数
        /// </summary>
        public string RecCount { get { return _recCount; } set { _recCount = value; OnPropertyChanged("RecCount"); } }

        #endregion

        #region

        /// <summary>
        /// 清空计数
        /// </summary>
        public void Clear()
        {
            SendCount = string.Empty;
            RecCount = string.Empty;
        }
        /// <summary>
        /// 增加发送计数
        /// </summary>
        /// <param name="len"></param>
        public void AddSend(int len)
        {
            SendCount=(SendCount.ToInt32() + len).ToString();
        }
        /// <summary>
        /// 增加接收计数
        /// </summary>
        /// <param name="len"></param>
        public void AddRec(int len)
        {
            RecCount = (RecCount.ToInt32() + len).ToString();
        }

        #endregion
    }
}
